#include <windows.h>
#include <QtGui>
#include <qt_windows.h>
#include <QRgb>
#include <QImage>
#include "BitBltCapture.h"

BitBltCapture::BitBltCapture()
{
}

void BitBltCapture::Capture(){
	myTimer.start();

}

void BitBltCapture::Release(){
	WorkTime = myTimer.elapsed();
}

int BitBltCapture::GetTime(){
	return WorkTime;
}

void BitBltCapture::MakeScreenshot(int x1, int y1, int x2, int y2){
	m_map = QPixmap::grabWindow(QApplication::desktop()->winId(),
									 x1,y1,x2,y2);
}

void BitBltCapture::SaveToFile(char* filename){
	m_map.save(filename);
}

QColor BitBltCapture::GetAverage(){
	QRgb rgb = m_map.scaled(1,1,Qt::IgnoreAspectRatio,Qt::SmoothTransformation).toImage().pixel(0,0);
	return QColor(rgb);
}

